<layout name="mun" />
<div class="operation_user clearfix">
    <div class="link fl"><a href="#">商城</a><span>&gt;&gt;</span><a href="#">商品管理</a><span>&gt;&gt;</span>添加分类</div>
    <div class="link fr">
        <a href="#" class="icon icon_i">首页</a><span></span>欢迎您！<span>Admin</span><a href="#" class="icon icon_e">退出</a>
    </div>
</div>
<div class="content clearfix">
    <div class="main">
        <!--右侧内容-->
        <div class="cont">
            <div class="title">添加分类</div>
            <div class="details">
                <div class="formDiv">
                <form id="uploadForm"  name="uploadForm"  method="post" target="tarframe"  enctype="multipart/form-data">
                    <div class="form-group">
                        <label for="userName" class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            商品名称
                            <input type="text" class="form-control" name="pName" placeholder="商品名称">
                            分类
                           
                          <select name="cId" class="form-control" name="cId" placeholder="分类">
                          <volist name="rs" id="vo">
                            <option value="{$vo.id}">{$vo.cname}</option>
                            </volist>
                      </select>
                            货号
                            <input type="text" class="form-control" name="pSn" placeholder="货号">
                            数量
                            <input type="text" class="form-control" name="pNum" placeholder="数量">
                            市场价
                            <input type="text" class="form-control" name="mPrice" placeholder="市场价">
                            网站价
                            <input type="text" class="form-control" name="iPrice" placeholder="网站价">
                            商品简介
                            <textarea id="pDesc" name="pDesc" style='width:600px; height:300px' placeholder="商品简介"></textarea>
                            商品图片                          
                            <label>
                            <input type="file" name="fileField" id="pImg" />
                          </label><br/>
                            商品上架时间
                          <input type="text" class="form-control" name="pubTime" placeholder="商品上架时间">
                            商品是否上架                            
                            <select name="isShow" class="form-control" id="isShow">
                              <option value="0">否</option>
                              <option value="1">是</option>
                            </select>
                            商品是否热卖                          
                            <select name="isHot" class="form-control" id="isHot">
                              <option value="0">否</option>
                              <option value="1">是</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button id="tijiao" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <SCRIPT src="__JS__jquery-1.9.1.min.js" type="text/javascript"></SCRIPT>
    <script charset="utf-8" src="__HomeJs__kindeditor-min.js"></script>
    <script charset="utf-8" src="__HomeJs__lang/zh_CN.js"></script>
    <script src="__JS__jquery.js"></script>
    <script type="text/javascript">
	    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name="pDesc"]', {
            resizeType : 1,
            allowPreviewEmoticons : false,
            allowImageUpload : false,
            items : [
                'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
                afterBlur: function(){
                	this.sync();
                	}
        });
    });
        $(function(){
       
            $('#tijiao').click(function(){
            	if($("#pImg").val() != ""){
                if($("#pName").val() != ""){
						$.ajax({
							type:"POST",
							url:"{:U('Addmodity/addData')}",
							cache: false,
							data: new FormData($('#uploadForm')[0]),
							contentType: false, //不可缺参数
							processData: false,     //不可缺参数
							success:function(data){
								if(data.status== 0){
									alert(data.info);
								}else{
									alert(data.info);
									location.href=data.url; 
								}
							}
						});
						return false;
                }else{
                    alert("商品名称不能为空");
                }
            }else{
            	alert("上传图片不能为空");
            	}});
        });
    </script>
